package com.example.simple_android_examples.receiver;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import com.example.simple_android.annotation.Receiver;
import com.example.simple_android_examples.constant.Constant;

// 程序启动时，则可以随Application对象启动被注册为全局广播
@Receiver(actions = Constant.NoStandardReceiverConstant.ACTION, methodName = "onReceiver")
//@Receiver(actions = Constant.NoStandardReceiverConstant.ACTION, whenToStart = com.example.simple_android.constant.Constant.ReceiverConstant.WAIT) // 程序启动时，不启动，由开发者决定启动时机
public class NoStandardReceiver {

    public void onReceiver(Context context, Intent intent) {
        if (Constant.NoStandardReceiverConstant.ACTION.equals(intent.getAction())) {
            Bundle extras = intent.getExtras();
            String string = extras.getString(Constant.NoStandardReceiverConstant.FLAG);
            System.err.println("非标准广播，接收到消息：".concat(string));
        }
    }
}
